<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="public/static" /}
</head>
<body>

{include file="public/nav" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" >
                        <div class="layui-inline layui-show-xs-block" style="width: 120px;">
                            <input type="text" name="name" placeholder="标题" autocomplete="off" class="layui-input" value="{$Request.param.name}"/>
                        </div>
                        <div class="layui-inline" style="width: 80px;">
                            <select name="status" id="status">
                                <option value="">状态</option>
                                <option value="1" {eq name="Request.param.status" value="1"} selected {/eq}>启用</option>
                                <option value="0" {eq name="Request.param.status" value="0"} selected {/eq}>禁用</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索</button>
                            <a href="{:url('Carousel/carouselList')}">
                                <button type="button" class="layui-btn"><i class="layui-icon">&#xe639;</i>清空</button>
                            </a>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    {eq name="check.CarouselcarouselAdd" value="1"}
                        <button class="layui-btn" onclick="common.openWindow('新增轮播图','{:url('Carousel/carouselAdd')}','500')">
                            <i class="layui-icon">&#xe654;</i>新增轮播图
                        </button>
                    {/eq}
                </div>
                <div class="layui-card-body layui-table-body">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>标题</th>
                                <th>图片</th>
                                <th>链接地址</th>
                                <th>排序</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {volist name="info" id="vo"}
                                <tr>
                                    <td>{$vo.ca_title}</td>
                                    <td>
                                        <a target="_blank" href="__upload__/{$vo.ca_image}">
                                            <img src="__upload__/{$vo.ca_image}" width="80" height="50">
                                        </a>
                                    </td>
                                    <td>{$vo.ca_url}</td>
                                    <td>{$vo.ca_sort}</td>
                                    <td>
                                        {eq name="vo.ca_status" value="1"}
                                            <span class="layui-badge layui-bg-green">启用</span>
                                        {else/}
                                            <span class="layui-badge">禁用</span>
                                        {/eq}
                                    </td>
                                    <td class="td-manage">
                                        {eq name="check.CarouselcarouselEdit" value="1"}
                                            <a href="javascript:;" onclick="common.openWindow('编辑轮播图','{:url('Carousel/carouselEdit',['id'=>$vo.ca_id])}','500')" >
                                                <i class="layui-icon">&#xe642;</i>编辑
                                            </a>
                                        {/eq}
                                        {eq name="check.CarouselcarouselDel" value="1"}
                                            <a href="javascript:;" onclick="dataDel(this,'{$vo.ca_id}')" >
                                                <i class="layui-icon">&#xe640;</i>删除
                                            </a>
                                        {/eq}
                                    </td>
                                </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$info|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /*全选*/
    common.selectCheckbox('checkbox','id[]');
    /*删除*/
    function dataDel(obj,id){
        layer.confirm('确认要删除这条数据吗？',function(){
            var index = layer.load();
            //发异步删除数据
            $.ajax({
               type:"post",
               url:"{:url('Carousel/carouselDel')}",
               data:{id:id},
               dataType:'json',
               success:function (data) {
                   if(data.status === 1){
                       $(obj).parents("tr").remove();
                       layer.msg(data.info, {icon: 6,time:1500});
                   }else{
                       layer.msg(data.info, {icon: 5,time:1500});
                   }
                   layer.close(index);

               },
               error:function (data) {
                   console.log(data);
                   layer.msg("不好意思，出现了一点问题", {icon: 5});
               }
            });
        });
    }
</script>
</html>